/*
 * @Author: 段丽军
 * @Date: 2021-05-21 14:17:09
 * @LastEditTime: 2021-12-14 14:09:36
 * @LastEditors: 段丽军
 * @Description: 
 * @FilePath: /el-web-basic/package/index_old.js
 */


import 'xe-utils'
import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

// 组件
import EBigDataSelectBatchSp from './components/secondary-packaging/big-data-select-batch/index.js';
import BigDataSelectSp from './components/secondary-packaging/big-data-select/index.js';
import DrawerSp from './components/secondary-packaging/drawer/index.js';
import SelectTreeSp from './components/secondary-packaging/select-tree/index.js';
import SwitchSp from './components/secondary-packaging/switch/index.js';
import TableSp from './components/secondary-packaging/table/index.js';
import ChatRecordSp from './components/secondary-packaging/chat-record/index.js';
import AudioPlaySp from './components/secondary-packaging/audio-play/index.js';
import TreeSp from './components/secondary-packaging/tree/index.js';
import DialogSp from './components/secondary-packaging/dialog/index.js';

import IconFontN from './components/native/icon-font/index.js';
import loadIconFont from './components/native/icon-font/src/load.js'; // 
import SelectFileN from './components/native/select-file/index.js';
import PreviewImageN from './components/native/preview-image/index.js';
import TimerN from './components/native/timer/index.js';
import UserCenterIframeN from './components/native/user-center-iframe/index.js';
import EImageCropperN from './components/native/image-cropper/index.js';
import EScrollPaneN from './components/native/scroll-pane/index.js';
import EEditorN from './components/native/editor/index.js';
import EButtonN from './components/native/button/index.js';
import EContainerListN from './components/native/container-list/index.js';
import EContainerListItemN from './components/native/container-list-item/index.js';
import EShowResizeN from './components/native/show-resize/index.js';
import ECountDownN from './components/native/count-down/index.js';
import ECountToN from './components/native/count-to/index.js';
import ECountTimeN from './components/native/count-time/index.js';

// 获取指令
let directives = {};
// 自动加载该目录下的所有文件
const files = require.context('./directives', true, /\.js$/);
// 根据文件名组织模块对象
files.keys().map(src => {
  const match = src.match(/\/(.+)\./);
  if (match && match.length >= 1) {
    const name = match[1];
    // const key = _.upperFirst(name);
    const moduleValue = files(src);
    if (moduleValue.default) {
      directives[name] = moduleValue.default;
    }
  }
});

import * as elementObj from 'element-ui';
// import locale from 'element-ui/src/locale';

let components = [
  EBigDataSelectBatchSp,
  BigDataSelectSp,
  DrawerSp,
  SelectTreeSp,
  SwitchSp,
  TableSp,
  ChatRecordSp,
  AudioPlaySp,
  TreeSp,
  DialogSp,

  IconFontN,
  SelectFileN,
  PreviewImageN,
  TimerN,
  UserCenterIframeN,
  EImageCropperN,
  EScrollPaneN,
  EEditorN,
  EButtonN,
  EContainerListN,
  EContainerListItemN,
  EShowResizeN,
  ECountDownN,
  ECountToN,
  ECountTimeN,
];

// for (const key in elementObj) {
//   console.log('elementObj[key]?.name --------- ', elementObj[key]?.name);
//   let exclude = [];
//   if (elementObj[key]?.name) {
//     components.push(elementObj[key]);
//   }
// }

const install = function (Vue, opts = {}) {
  // locale.use(opts.locale);
  // locale.i18n(opts.i18n);

  // 注册组件
  components.forEach(component => {
    Vue.component(component.name, component);
  });

  // const { Loading, MessageBox, Notification, Message } = elementObj;

  Vue.use(elementObj.install, opts);
  // Vue.use(Loading.directive);


  // 注册指令
  Object.keys(directives || {}).forEach(key => {
    Vue.directive(key, directives[key]);
  });

  // Vue.prototype.$ELEMENT = {
  //   size: opts.size || 'medium',
  //   zIndex: opts.zIndex || 2000,
  // };

  // Vue.prototype.$loading = Loading.service;
  // Vue.prototype.$msgbox = MessageBox;
  // Vue.prototype.$alert = MessageBox.alert;
  // Vue.prototype.$confirm = MessageBox.confirm;
  // Vue.prototype.$prompt = MessageBox.prompt;
  // Vue.prototype.$notify = Notification;
  // Vue.prototype.$message = Message;


  Vue.use(VXETable)
};

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue);
}

let Loading = elementObj.loading,
  MessageBox = elementObj.MessageBox,
  Notification = elementObj.Notification,
  Message = elementObj.Message;

export {
  loadIconFont,

  EBigDataSelectBatchSp,
  BigDataSelectSp,
  DrawerSp,
  SelectTreeSp,
  SwitchSp,
  TableSp,
  ChatRecordSp,
  AudioPlaySp,
  TreeSp,
  DialogSp,

  IconFontN,
  SelectFileN,
  PreviewImageN,
  TimerN,
  UserCenterIframeN,
  EImageCropperN,
  EScrollPaneN,
  EEditorN,
  EButtonN,
  EContainerListN,
  EContainerListItemN,
  EShowResizeN,
  ECountDownN,
  ECountToN,
  ECountTimeN,

  Loading,
  MessageBox,
  Notification,
  Message,
}

export default {
  version: '0.1.106',
  loadIconFont,
  locale: locale.use,
  i18n: locale.i18n,
  install,

  EBigDataSelectBatchSp,
  BigDataSelectSp,
  DrawerSp,
  SelectTreeSp,
  SwitchSp,
  TableSp,
  ChatRecordSp,
  AudioPlaySp,
  TreeSp,
  DialogSp,

  IconFontN,
  SelectFileN,
  PreviewImageN,
  TimerN,
  UserCenterIframeN,
  EImageCropperN,
  EScrollPaneN,
  EEditorN,
  EButtonN,
  EContainerListN,
  EContainerListItemN,
  EShowResizeN,
  ECountDownN,
  ECountToN,
  ECountTimeN,
};
